import unittest
from word import *

class TestWord(unittest.TestCase):
    def setUp(self):
        self.word_1 = word("108", 4)
        self.word_2 = word("108", 4)
        self.word_3 = word("design", 4)
        self.word_4 = word("design", 4)
        self.word_4.count = 5
  
    def testEqual(self):
        self.assertEqual(self.word_1.__eq__(self.word_2), True)
        self.assertEqual(self.word_1.__eq__(self.word_3), False)
        self.assertEqual(self.word_3.__eq__(self.word_4), False)
    
    def testGetFileName(self): 
        self.word_2.incrementCount()
        self.assertEqual(self.word_2.count, 2)
    
    def testGetAvgLoc(self):
        self.word_1.updateWord(9)
        self.word_1.updateWord(2)
        avg = self.word_1.getAvgLoc()
        self.assertEqual(avg, 5)
    
    def testUpdateWord(self):
        self.word_1.updateWord(9)
        self.word_1.updateWord(2)
        self.assertEqual(self.word_1.count, 3)
        self.assertEqual(self.word_1.locations, [4,9,2])
        
if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(TestWord)
    unittest.TextTestRunner(verbosity=2).run(suite)